package com.ruibang.glass.material.controller;

import com.ruibang.glass.material.domain.req.ApproveProcessReq;
import com.ruibang.glass.material.domain.req.ycl.ManageOutBoundReq;
import com.ruibang.glass.material.entity.MaterialALLOutboundManagement;
import com.ruibang.glass.material.service.GMaterialAllOutboundManagementService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 出库申请 前段控制器
 * </p>
 *
 * @author mameng
 * @since 2024-02-05
 */
@RestController
@RequestMapping("/api/material/cksq/out/bound/manage")
@Api(value = "出库申请", tags = {"出库申请"})
public class MaterialSQCKOutBoundController {

    @Autowired
    private GMaterialAllOutboundManagementService materialOutboundManagementService;


    @PostMapping("/list")
    @ApiOperation(value = "出库申请管理列表", response = ResultBody.class)
    public ResultBody getPageList(@RequestBody ManageOutBoundReq materialManagementReq) {
        return ResultBody.success(materialOutboundManagementService.getPage(materialManagementReq));
    }

    @PostMapping("/update")
    @ApiOperation(value = "更新", response = ResultBody.class)
    public ResultBody updateById(@RequestBody MaterialALLOutboundManagement materialManagement) {
        materialOutboundManagementService.updateMaterialZPKOutboundManagement(materialManagement);
        return ResultBody.success();
    }


    @PostMapping("/add")
    @ApiOperation(value = "新增", response = ResultBody.class)
    public ResultBody addMaterialZPKOutboundManagement(@RequestBody MaterialALLOutboundManagement materialManagement) {
        materialOutboundManagementService.addMaterialZPKOutboundManagement(materialManagement);
        return ResultBody.success();
    }

    @PostMapping("/approveProcess")
    @ApiOperation(value = "审批流程", response = ResultBody.class)
    public ResultBody approveProcess(@RequestBody ApproveProcessReq processReq) {
        return ResultBody.success(materialOutboundManagementService.approveProcess(processReq));
    }

    @PostMapping("/addByPurchaseReturn")
    @ApiOperation(value = "采购退货新增", response = ResultBody.class)
    public ResultBody addByPurchaseReturn(@RequestBody MaterialALLOutboundManagement materialManagement) {
        materialOutboundManagementService.addByPurchaseReturn(materialManagement);
        return ResultBody.success();
    }

    @GetMapping("/processNotice/{businessId}")
    @ApiOperation(value = "流程处理通知", response = ResultBody.class)
    public ResultBody processNotice(@PathVariable("businessId") String businessId) {
        materialOutboundManagementService.processNotice(businessId);
        return ResultBody.success();
    }
    @GetMapping("/processYCLNotice/{businessId}")
    @ApiOperation(value = "原材料流程通知", response = ResultBody.class)
    public ResultBody processYCLNotice(@PathVariable("businessId") String businessId) {
        materialOutboundManagementService.processYCLNotice(businessId);
        return ResultBody.success();
    }

    @PostMapping("/addYclList")
    @ApiOperation(value = "原材料出库批量添加", response = ResultBody.class)
    public ResultBody addMaterialYClOutboundManagement(@RequestBody MaterialALLOutboundManagement materialALLOutboundManagement) {
        materialOutboundManagementService.addMaterialYClOutboundManagement(materialALLOutboundManagement);
        return ResultBody.success();
    }

    @PostMapping("/addByPurchaseYclList")
    @ApiOperation(value = "原材料出库批量添加", response = ResultBody.class)
    public ResultBody addByPurchaseYclList(@RequestBody MaterialALLOutboundManagement materialALLOutboundManagement) {
        materialOutboundManagementService.addByPurchaseYclList(materialALLOutboundManagement);
        return ResultBody.success();
    }

    @GetMapping("/getOne/{id}")
    @ApiOperation(value = "详情", response = ResultBody.class)
    public ResultBody getOneById(@PathVariable("id") String id) {
        return ResultBody.success(materialOutboundManagementService.getMaterialALLOutboundManagementById(id));
    }

    @GetMapping("/getById/{id}")
    @ApiOperation(value = "详情", response = ResultBody.class)
    public ResultBody getById(@PathVariable("id") String id) {
        return ResultBody.success(materialOutboundManagementService.getById(id));
    }


    @PostMapping("/deleteChoose")
    @ApiOperation(value = "选中删除", response = ResultBody.class)
    public ResultBody deleteChoose(@RequestBody MaterialALLOutboundManagement materialManagement) {
        materialOutboundManagementService.deleteChooseIds(materialManagement.getIds());
        return ResultBody.success();
    }


    @PostMapping("/updateItemHouse")
    @ApiOperation(value = "完成出库", response = ResultBody.class)
    public ResultBody updateItemHouse(@RequestBody MaterialALLOutboundManagement materialManagement) {
        materialOutboundManagementService.updateItemHouse(materialManagement);
        return ResultBody.success();
    }

    @GetMapping("/getDictList")
    @ApiOperation(value = "字典下拉", response = ResultBody.class)
    public ResultBody updateItemHouse() {
        return materialOutboundManagementService.getDictList();
    }



    @GetMapping("/getOutNumber")
    @ApiOperation(value = "获取出库单号", response = ResultBody.class)
    public ResultBody getOutNumber() {
        return ResultBody.success(materialOutboundManagementService.getOutNumber());
    }




}
